Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
test-runner
Advanced tools
A minimal test runner built around a single, core principle: if a test function completes successfully (or fulfils), it passes. If it throws (or rejects) it fails. It has no opinion how you write tests, or which (if any) assertion library you use.
const TestRunner = require('test-runner')
const runner = new TestRunner()
Passing test, sync.
runner.test('this will pass', function () {
const thought = 'Nothing failing here.'
})
Passing test, async.
runner.test('this will also pass', function () {
return Promise.resolve('Nothing failing here.')
})
Failing test, sync.
runner.test('this will fail', function () {
throw new Error('Definitely something wrong here.')
})
Failing test, async.
runner.test('this will also fail', function () {
return Promise.reject('Definitely something wrong here.')
})
To run the tests, execute the script:
$ node test.js
... or use the command-line tool to test multiple files:
$ test-runner test/*.js
EventEmitter
⏏
Promise
Array
EventEmitter
⏏Register tests and run them sequentially or in parallel. By default, testing begins automatically but can be set to start manually.
Kind: Exported class
Extends: EventEmitter
Param | Type | Description |
---|---|---|
[options] | object | |
[options.log] | function | Specify a custom log function. Defaults to console.log . |
[options.manualStart] | boolean | If true , you must call runner.start() manually. |
[options.sequential] | boolean | Run async tests sequentially. |
Promise
Begin testing. You'll only need to use this method when manualStart
is true
.
Kind: instance method of TestRunner
Fulfil: Array
- Resolves with an array containing the return value of each test.
Register a test.
Kind: instance method of TestRunner
Chainable
Param | Type | Description |
---|---|---|
name | string | Each name supplied must be unique to the runner instance. |
testFunction | function | The test function. If it throws or rejects, the test will fail. |
No-op. Use this method when you want a test to be skipped.
Kind: instance method of TestRunner
Chainable
Only run this and other tests registered with only
.
Kind: instance method of TestRunner
Chainable
Param | Type |
---|---|
name | string |
testFunction | function |
Array
Run one or more test files. The output will be an array containing the export value from each module.
Kind: static method of TestRunner
Param | Type | Description |
---|---|---|
globs | Array.<string> | One or more file paths or glob expressions. |
© 2016-17 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.
FAQs
Fully-featured, lightweight command-line test runner
The npm package test-runner receives a total of 304 weekly downloads. As such, test-runner popularity was classified as not popular.
We found that test-runner demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.